Skip to content

Conversation

@rishi-jat
Copy link
Contributor

Summary

  • Add Valkey backend support as Redis-compatible alternative
  • Implement RDMA configuration for future high-performance scenarios
  • Add comprehensive test suite for Valkey functionality
  • Update documentation with Valkey configuration options
  • Provide example implementation and usage guide
  • Maintain full backward compatibility with existing Redis backend

Fixes #134

- Add Valkey backend support as Redis-compatible alternative
- Implement RDMA configuration for future high-performance scenarios
- Add comprehensive test suite for Valkey functionality
- Update documentation with Valkey configuration options
- Provide example implementation and usage guide
- Maintain full backward compatibility with existing Redis backend

Fixes llm-d#134
@rishi-jat rishi-jat requested a review from vMaroon as a code owner October 4, 2025 14:16
Copilot AI review requested due to automatic review settings October 4, 2025 14:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds Valkey backend support as a Redis-compatible alternative for KV-cache indexing, including RDMA configuration for high-performance scenarios. The implementation maintains full backward compatibility with the existing Redis backend while providing enhanced performance options.

  • Add Valkey backend with RDMA support configuration
  • Implement comprehensive test suite for Valkey functionality
  • Provide example implementation and configuration documentation

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
pkg/kvcache/kvblock/valkey_test.go Comprehensive test suite for Valkey backend functionality
pkg/kvcache/kvblock/redis.go Extended Redis implementation to support Valkey backend with RDMA
pkg/kvcache/kvblock/index.go Added Valkey configuration support to index factory
examples/valkey_example/main.go Complete example demonstrating Valkey usage
examples/valkey_example/README.md Documentation for Valkey example usage
examples/valkey_configuration.md Configuration guide for Valkey backend
docs/configuration.md Updated configuration documentation with Valkey options
docs/architecture.md Added Valkey backend description to architecture
README.md Updated main README with Valkey example reference

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

shouldSucceed: true,
},
{
name: "valkey with RDMA enabled",
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra trailing space after comma should be removed.

Suggested change
name: "valkey with RDMA enabled",
name: "valkey with RDMA enabled",

Copilot uses AI. Check for mistakes.
name: "valkeys:// SSL URL scheme",
config: &RedisIndexConfig{
Address: "valkeys://" + server.Addr(),
BackendType: "valkey",
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra trailing space after comma should be removed.

Suggested change
BackendType: "valkey",
BackendType: "valkey",

Copilot uses AI. Check for mistakes.
expectError: false,
},
{
name: "valkey:// scheme",
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra trailing space after comma should be removed.

Suggested change
name: "valkey:// scheme",
name: "valkey:// scheme",

Copilot uses AI. Check for mistakes.
// DefaultValkeyIndexConfig returns a default configuration for Valkey.
func DefaultValkeyIndexConfig() *RedisIndexConfig {
return &RedisIndexConfig{
Address: "valkey://127.0.0.1:6379",
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra trailing space after comma should be removed.

Suggested change
Address: "valkey://127.0.0.1:6379",
Address: "valkey://127.0.0.1:6379",

Copilot uses AI. Check for mistakes.
// Convert valkey:// to redis:// for protocol compatibility
config.Address = strings.Replace(config.Address, "valkey://", "redis://", 1)
} else if strings.HasPrefix(config.Address, "valkeys://") {
// Convert valkeys:// to rediss:// for SSL protocol compatibility
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra trailing space after compatibility should be removed.

Suggested change
// Convert valkeys:// to rediss:// for SSL protocol compatibility
// Convert valkeys:// to rediss:// for SSL protocol compatibility

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.


const (
envValkeyAddr = "VALKEY_ADDR"
envValkeyEnableRDMA = "VALKEY_ENABLE_RDMA"
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra trailing space after string should be removed.

Suggested change
envValkeyEnableRDMA = "VALKEY_ENABLE_RDMA"
envValkeyEnableRDMA = "VALKEY_ENABLE_RDMA"

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

// Test prompts to demonstrate caching behavior
prompts := []string{
"Hello, how are you today?",
"What is the weather like?",
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra trailing space after comma should be removed.

Suggested change
"What is the weather like?",
"What is the weather like?",

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

@rishi-jat rishi-jat mentioned this pull request Oct 4, 2025
Copy link
Member

@vMaroon vMaroon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rishi-jat thank you for the contribution - looks great overall! I added a few minor comments.

func demonstrateValkeyOperations(ctx context.Context, indexer *kvcache.Indexer) error {
logger := klog.FromContext(ctx).WithName("valkey-demo")

// Test prompts to demonstrate caching behavior
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be preferable to reuse the testdata package's content as done in the other examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

logger.Info("Adding cache entries manually to demonstrate Valkey backend")

// Simulate cache entries for the first prompt
firstPromptKeys := []kvblock.Key{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expanding on the above point - this example would fail as these hashes will not be regenerated by the indexer. It is best to use the content of the testdata package, including the pre-calculated hashes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

}

// Future: Add RDMA configuration for Valkey when supported
if config.BackendType == "valkey" && config.EnableRDMA {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear - only the configuration is not supported, but RDMA will still work if configured in the valkey instance?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

@rishi-jat
Copy link
Contributor Author

@vMaroon Thanks for the review! I’ll address all the suggestions as soon as possible.

- Use testdata package in Valkey example as requested by @vMaroon
- Replace hardcoded hashes with pre-calculated testdata.PromptHashes
- Fix example to demonstrate proper cache behavior with real data
- Add clarification about RDMA support in Go client vs server
- Clean up code formatting and remove trailing spaces
- Add implementation documentation

Addresses feedback from PR llm-d#139

Signed-off-by: Rishi Jat <[email protected]>
@rishi-jat
Copy link
Contributor Author

@vMaroon I’ve implemented all the suggested changes. Please let me know if I missed anything or if further adjustments are needed. Thanks!

@rishi-jat
Copy link
Contributor Author

Also, since this PR is part of my Hacktoberfest contributions, could you please add the hacktoberfest-accepted label?
image

@vMaroon
Copy link
Member

vMaroon commented Oct 14, 2025

@vMaroon I’ve implemented all the suggested changes. Please let me know if I missed anything or if further adjustments are needed. Thanks!

Thanks Rishi - can you confirm that the examples run as expected? Then we'll be good to go after fixing the linting issue.

Also, since this PR is part of my Hacktoberfest contributions, could you please add the hacktoberfest-accepted label? image

Sure! Thank you for pointing this out.

- Fix errcheck issues by properly handling server.Close() in defer functions
- Replace if-else chain with switch statement for better readability
- Remove duplicate code branches in URL scheme handling
- Add log message for RDMA configuration to avoid empty branch warning
- Simplify createValkeyConfig() to remove unused error return
- All tests continue to pass after linting fixes

Fixes linting errors in PR llm-d#139

Signed-off-by: Rishi Jat <[email protected]>
@rishi-jat rishi-jat requested a review from vMaroon October 16, 2025 09:25
@rishi-jat
Copy link
Contributor Author

@vMaroon I fixed the CI issue.

@rishi-jat
Copy link
Contributor Author

please review when you get a chance.

- Fix errcheck warnings by properly checking type assertion results
- Fix gofumpt and goimports formatting issues in redis.go
- Ensure all code follows project linting standards
@vMaroon
Copy link
Member

vMaroon commented Oct 19, 2025

Thanks @rishi-jat!

/lgtm
/approve

@github-actions github-actions bot added the lgtm label Oct 19, 2025
@github-actions github-actions bot merged commit cf33a2d into llm-d:main Oct 19, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Valkey and RDMA support

2 participants